package com.ydsungan.serviceimpl;

import com.ydsungan.bean.Clockin;
import com.ydsungan.dao.ClockinDao;
import com.ydsungan.dao.SigninDao;
import com.ydsungan.daoimpl.ClockinDaoImpl;
import com.ydsungan.daoimpl.SigninDaoImpl;
import com.ydsungan.service.ClockinService;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Map;

public class ClockinServiceImpl implements ClockinService {

    SqlSessionFactory sqlSessionFactory = null;
    private ClockinDao clockinDao = null;

    public ClockinServiceImpl() throws IOException {
        //获取sqlSessionFactory对象
        SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder();
        InputStream inputStream = Resources.getResourceAsStream("mybatis-config.xml");
        sqlSessionFactory = builder.build(inputStream);
        clockinDao = new ClockinDaoImpl(this.sqlSessionFactory);
    }


    @Override
    public List<Clockin> findClockinByMap(Map<String, Object> map) {

        return clockinDao.findClockinByMap(map);
    }

    @Override
    public void addClockin(Clockin clockin) {
        clockinDao.addClockin(clockin);
    }
}
